//
//  AccountNavigationController.swift
//  GhostWorld
//
//  Created by Kam on 2018/5/14.
//  Copyright © 2018 LKGood. All rights reserved.
//

import UIKit

class AccountNavigationController: BaseNavigationController {
  
  // MARK: - Private methods
  
  @objc private func resetRootView() {
    if UserManager.shared.currentUser != nil {
      let storyboard = UIStoryboard(name: "Account", bundle: nil)
      let accountHomeViewController = storyboard.instantiateViewController(withIdentifier: "AccountHomeViewController")
      setViewControllers([accountHomeViewController], animated: true)
      
    } else {
      let storyboard = UIStoryboard(name: "Account", bundle: nil)
      let loginViewController = storyboard.instantiateViewController(withIdentifier: "LoginViewController")
      setViewControllers([loginViewController], animated: true)
    }
  }
  
  // MARK: - Lifecycle
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    NotificationCenter.default.addObserver(self, selector: #selector(resetRootView), name: .currentUserUpdated, object: nil)
    
    resetRootView()
  }
  
  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }
  
  deinit {
    NotificationCenter.default.removeObserver(self)
  }
  
  // MARK: - IBActions
  
  
  
  // MARK: - Public methods
  
  
}
